#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

typedef struct stu {
	int age;
	char name[10];
	float tall;
}stu;

void read() {
	stu li = { 0 };
	FILE* pfile = fopen("test.txt", "r");
	if ( NULL == pfile) {
		perror("read");
		return;
	}
	/*char buf[600] = { 0 };
	fgets(buf, 600, pfile);
	printf("%s", buf);*/
	fscanf(pfile, "%d%s%f", &li.age, li.name, &li.tall);
	printf("%d %s %f", li.age,li.name,li.tall);
	fclose(pfile);
}

void write() {
	stu li = { 23,"zhangsan",33.54 };
	FILE* pfile = fopen("test.txt", "w");
	if (NULL == pfile) {
		perror("write");
		return;
	}
	//fputs("hello\n", pfile);
	//fputs("nihao\n", pfile);
	fprintf(pfile, "%-4d %66s %.2f\n", li.age, li.name, li.tall);
	fclose(pfile);
}

int main() {
	
	write();
	read();
	return 0;
}